import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';

export const cardList = (() => {
  const result: any[] = [];
  for (let i = 0; i < 6; i++) {
    result.push({
      title: '仪器设备',
      icon: 'logos:vue',
      color: '#1890ff',
      active: '100',
      new: '1,799',
      download: 'bx:bx-download',
    });
  }
  return result;
})();

/**
 * 智能查验-多维特征数据库-查询字段
 */
export const searchFormSchema: FormSchema[] = [
  {
    label: '名称',
    field: 'keyword',
    component: 'JInput',
    colProps: { span: 6 },
  },
];
/**
 * 智能查验-多维特征数据库-表格数据
 */
export const columns: BasicColumn[] = [
  {
    title: '序号',
    dataIndex: '',
    key: 'rowIndex',
    width: 60,
    align: 'center',
    customRender: ({ index }) => {
      return parseInt(index) + 1;
    },
  },
  {
    title: '报关单号',
    dataIndex: 'name', //字段不对
    width: 120,
  },
  {
    title: '报关日期',
    dataIndex: 'testStdNo',
    width: 100,
  },
  {
    title: '起运',
    dataIndex: 'testStdName',
    width: 120,
  },
  {
    title: '抵达',
    dataIndex: 'labName',
    width: 80,
  },
  {
    title: '货物名称',
    dataIndex: 'orgName',
    width: 100,
  },
  {
    title: '货物描述',
    dataIndex: 'catName',
    width: 100,
  },
  {
    title: '货物数量',
    dataIndex: 'catName',
    width: 100,
  },
  {
    title: '货物单位',
    dataIndex: 'catName',
    width: 100,
  },
  {
    title: '所属公司',
    dataIndex: 'catName',
    width: 100,
  },
  {
    title: '联系人',
    dataIndex: 'catName',
    width: 100,
  },
  {
    title: '押运员',
    dataIndex: 'catName',
    width: 100,
  },
  {
    title: '比对结果',
    dataIndex: 'catName',
    width: 100,
  },
];
/**
 * 风险信息库-表单数据
 */
export const formSchema: FormSchema[] = [
  {
    label: '检测项',
    field: 'name',
    component: 'Input',
  },
  {
    label: '检测方法号',
    field: 'testStdNo',
    component: 'Input',
  },
  {
    label: '检测方法名称',
    field: 'testStdName',
    component: 'Input',
  },
  {
    label: '实验室',
    field: 'labName',
    component: 'Input',
  },
  {
    label: '技术中心',
    field: 'orgName',
    component: 'Input',
  },
  {
    label: '检测类型',
    field: 'catName',
    component: 'Input',
  },
];
/**
 *企业报关信息-查询字段
 */
export const declarationInfoSearchFormSchema: FormSchema[] = [
  {
    label: '报关单号',
    field: 'id',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '起运港口',
    field: 'departureCountry',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '抵达港口',
    field: 'destinationCountry',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '报关日期',
    field: 'departureTime',
    component: 'DatePicker',
    colProps: { span: 6 },
  },
  {
    label: '运输方式',
    field: 'dept',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'transportation_mode',
      stringToNumber: true,
    },
    colProps: { span: 6 },
  },
  {
    label: '货物重量',
    field: 'goodsPrice',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '货物单位',
    field: 'goodsUnit',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'cargo_unit',
      stringToNumber: true,
    },
    colProps: { span: 6 },
  },
  {
    label: '货物名称',
    field: 'goodsName',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '货物描述',
    field: 'goodsDesc',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '所属公司',
    field: 'subordinateCompany',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '联系人',
    field: 'linkManId',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '联系人电话',
    field: 'cName',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '押运人',
    field: 'supercargoId',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '押运人电话',
    field: 'cName',
    component: 'JInput',
    colProps: { span: 6 },
  },
];
/**
 * 企业报关信息-表格数据
 */
export const declarationInfoColumns: BasicColumn[] = [
  {
    title: '序号',
    dataIndex: '',
    key: 'rowIndex',
    width: 60,
    align: 'center',
    customRender: ({ index }) => {
      return parseInt(index) + 1;
    },
  },
  {
    title: '报关单号',
    dataIndex: 'customsDeclarationId', //字段不对
    width: 120,
  },
  {
    title: '报关日期',
    dataIndex: 'standardTime',
    width: 100,
  },
  {
    title: '起运',
    dataIndex: 'utcTiming',
    width: 120,
  },
  {
    title: '抵达',
    dataIndex: 'longitude',
    width: 80,
  },
  {
    title: '货物名称',
    dataIndex: 'latitude',
    width: 100,
  },
  {
    title: '货物描述',
    dataIndex: 'temperature',
    width: 100,
  },
  {
    title: '货物数量',
    dataIndex: 'humility',
    width: 100,
  },
  {
    title: '货物单位',
    dataIndex: 'type',
    width: 100,
  },
  {
    title: '所属公司',
    dataIndex: 'data',
    width: 100,
  },
  {
    title: '联系人',
    dataIndex: 'detectResult',
    width: 100,
  },
  {
    title: '押运员',
    dataIndex: 'schedule',
    width: 100,
  },
];
/**
 * 企业报关信息-表单数据
 */
export const declarationInfoFormSchema: FormSchema[] = [
  {
    label: '报关单号',
    field: 'customsDeclarationId',
    component: 'Input',
  },
  {
    label: '报关日期',
    field: 'standardTime',
    component: 'DatePicker',
  },
  {
    label: '起运',
    field: 'utcTiming',
    component: 'Input',
  },
  {
    label: '抵达',
    field: 'longitude',
    component: 'Input',
  },
  {
    label: '货物名称',
    field: 'latitude',
    component: 'Input',
  },
  {
    label: '货物描述',
    field: 'temperature',
    component: 'Input',
  },
  {
    label: '货物数量',
    field: 'humility',
    component: 'Input',
  },
  {
    label: '货物单位',
    field: 'goodsUnit',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'cargo_unit',
      stringToNumber: true,
    },
  },
  {
    label: '所属公司',
    field: 'data',
    component: 'Input',
  },
  {
    label: '联系人',
    field: 'detectResult',
    component: 'Input',
  },
  {
    label: '押运员',
    field: 'schedule',
    component: 'Input',
  },
];
/**
 *风险信息数据采集-查询字段
 */
export const dataCollectionSearchFormSchema: FormSchema[] = [
  {
    label: '名称',
    field: 'cName',
    component: 'JInput',
    colProps: { span: 6 },
  },
];
/**
 * 风险信息数据采集-表格数据
 */
export const dataCollectionColumns: BasicColumn[] = [
  {
    title: '序号',
    dataIndex: '',
    key: 'rowIndex',
    width: 60,
    align: 'center',
    customRender: ({ index }) => {
      return parseInt(index) + 1;
    },
  },
  {
    title: '报关单id',
    dataIndex: 'customsDeclarationId', //字段不对
    width: 120,
  },
  {
    title: '记录时间',
    dataIndex: 'standardTime',
    width: 100,
  },
  {
    title: '记录UTC时间',
    dataIndex: 'utcTiming',
    width: 120,
  },
  {
    title: '经度',
    dataIndex: 'longitude',
    width: 80,
  },
  {
    title: '纬度',
    dataIndex: 'latitude',
    width: 100,
  },
  {
    title: '环境温度',
    dataIndex: 'temperature',
    width: 100,
  },
  {
    title: '环境湿度',
    dataIndex: 'humility',
    width: 100,
  },
  {
    title: '熏蒸气体类型',
    dataIndex: 'type',
    width: 100,
  },
  {
    title: '熏蒸气体浓度',
    dataIndex: 'data',
    width: 100,
  },
  {
    title: '原始图像',
    dataIndex: 'avatar',
    width: 100,
    customRender: render.renderAvatar,
  },
  {
    title: '检测模型结果',
    dataIndex: 'detectResult',
    width: 100,
  },
  {
    title: '进度(百分比)',
    dataIndex: 'schedule',
    width: 100,
  },
  {
    title: '是否预警',
    dataIndex: 'earlyWarning',
    width: 100,
  },
];
/**
 * 风险信息数据采集-表单数据
 */
export const dataCollectionFormSchema: FormSchema[] = [
  {
    label: '报关单id',
    field: 'customsDeclarationId',
    component: 'Input',
  },
  {
    label: '记录时间',
    field: 'standardTime',
    component: 'DatePicker',
  },
  {
    label: '记录UTC时间',
    field: 'utcTiming',
    component: 'DatePicker',
  },
  {
    label: '经度',
    field: 'longitude',
    component: 'Input',
  },
  {
    label: '纬度',
    field: 'latitude',
    component: 'Input',
  },
  {
    label: '环境温度',
    field: 'temperature',
    component: 'Input',
  },
  {
    label: '环境湿度',
    field: 'humility',
    component: 'Input',
  },
  {
    label: '熏蒸气体类型',
    field: 'type',
    component: 'Input',
  },
  {
    label: '熏蒸气体浓度',
    field: 'data',
    component: 'Input',
  },
  {
    label: '原始图像',
    field: 'avatar',
    component: 'JImageUpload',
    componentProps: {
      fileMax: 1,
    },
  },
  {
    label: '检测模型结果',
    field: 'detectResult',
    component: 'Input',
  },
  {
    label: '进度(百分比)',
    field: 'schedule',
    component: 'Input',
  },
  {
    label: '是否预警',
    field: 'earlyWarning',
    component: 'RadioGroup',
    defaultValue: 1,
    componentProps: ({ formModel }) => {
      return {
        options: [
          { label: '是', value: 1, key: '1' },
          { label: '否', value: 2, key: '2' },
        ],
        onChange: () => {
          formModel.userIdentity == 1 && (formModel.departIds = []);
        },
      };
    },
  },
];

export const recycleColumns: BasicColumn[] = [
  {
    title: '用户账号',
    dataIndex: 'username',
    width: 100,
  },
  {
    title: '用户姓名',
    dataIndex: 'realname',
    width: 100,
  },
  {
    title: '头像',
    dataIndex: 'avatar',
    width: 80,
    customRender: render.renderAvatar,
  },
  {
    title: '性别',
    dataIndex: 'sex',
    width: 80,
    sorter: true,
    customRender: ({ text }) => {
      return render.renderDict(text, 'sex');
    },
  },
];

export const formPasswordSchema: FormSchema[] = [
  {
    label: '用户账号',
    field: 'username',
    component: 'Input',
    componentProps: { readOnly: true },
  },
  {
    label: '登录密码',
    field: 'password',
    component: 'StrengthMeter',
    componentProps: {
      placeholder: '请输入登录密码',
    },
    rules: [
      {
        required: true,
        message: '请输入登录密码',
      },
    ],
  },
  {
    label: '确认密码',
    field: 'confirmPassword',
    component: 'InputPassword',
    dynamicRules: ({ values }) => rules.confirmPassword(values, true),
  },
];

export const formAgentSchema: FormSchema[] = [
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    field: 'userName',
    label: '用户名',
    component: 'Input',
    componentProps: {
      readOnly: true,
      allowClear: false,
    },
  },
  {
    field: 'agentUserName',
    label: '代理人用户名',
    required: true,
    component: 'JSelectUser',
    componentProps: {
      rowKey: 'username',
      labelKey: 'realname',
      maxSelectCount: 10,
    },
  },
  {
    field: 'startTime',
    label: '代理开始时间',
    component: 'DatePicker',
    required: true,
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      placeholder: '请选择代理开始时间',
    },
  },
  {
    field: 'endTime',
    label: '代理结束时间',
    component: 'DatePicker',
    required: true,
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      placeholder: '请选择代理结束时间',
    },
  },
  {
    field: 'status',
    label: '状态',
    component: 'JDictSelectTag',
    defaultValue: '1',
    componentProps: {
      dictCode: 'valid_status',
      type: 'radioButton',
    },
  },
];

export const formQuitAgentSchema: FormSchema[] = [
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    field: 'userName',
    label: '用户名',
    component: 'Input',
    componentProps: {
      readOnly: true,
      allowClear: false,
    },
  },
  {
    field: 'agentUserName',
    label: '交接人员',
    required: true,
    component: 'JSelectUser',
    componentProps: {
      rowKey: 'username',
      labelKey: 'realname',
      maxSelectCount: 1,
    },
  },
  {
    field: 'startTime',
    label: '交接开始时间',
    component: 'DatePicker',
    required: true,
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      placeholder: '请选择交接开始时间',
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'endTime',
    label: '交接结束时间',
    component: 'DatePicker',
    required: true,
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      placeholder: '请选择交接结束时间',
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'status',
    label: '状态',
    component: 'JDictSelectTag',
    defaultValue: '1',
    componentProps: {
      dictCode: 'valid_status',
      type: 'radioButton',
    },
  },
];

//租户用户列表
export const userTenantColumns: BasicColumn[] = [
  {
    title: '用户账号',
    dataIndex: 'username',
    width: 120,
  },
  {
    title: '用户姓名',
    dataIndex: 'realname',
    width: 100,
  },
  {
    title: '头像',
    dataIndex: 'avatar',
    width: 120,
    customRender: render.renderAvatar,
  },
  {
    title: '手机号',
    dataIndex: 'phone',
    width: 100,
  },
  {
    title: '部门',
    width: 150,
    dataIndex: 'orgCodeTxt',
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 80,
    customRender: ({ text }) => {
      if (text === '1') {
        return '正常';
      } else if (text === '3') {
        return '审批中';
      } else {
        return '已拒绝';
      }
    },
  },
];

//用户租户搜索表单
export const userTenantFormSchema: FormSchema[] = [
  {
    label: '账号',
    field: 'username',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '名字',
    field: 'realname',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '性别',
    field: 'sex',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'sex',
      placeholder: '请选择性别',
      stringToNumber: true,
    },
    colProps: { span: 6 },
  },
];
